import random

shop = [
    ["火锅", 300],
    ["乱炖", 200],
    ["炸鸡架", 20],
    ["烤面筋", 8],
    ["好煎饼", 15],
    ["甜豆浆", 2],
    ["周杰伦牌手抓饼", 6],
    ["酸甜烤冷面", 13],
    ["臭豆腐", 15],
    ["锅盔", 18]
]
# a=random.choice(shop)
# print(a)
car = []
money = 1000
hua=0
man=200
you=random.randint(0,1)
if you==1:
    print('今日有优惠券：”好煎饼“有5张券打8折！本次购买随意使用!')
    hao=5
else:
    print('今日有优惠券：”周杰伦牌手抓饼“有10张券打9折！本次购买随意使用!')
    zhou=10
print('商品列表：')
for i, z in enumerate(shop):
    print(i, z)
while True:
    buy = input("请输入商品编码：")
    if buy.isdigit():
        buy = int(buy)
        if 0 <= buy < len(shop):
            if money >= shop[buy][1]:
                car.append(shop[buy])
                if you==1 and buy==4 and hao>0:
                    money = money - (shop[buy][1])*0.8
                    hua=hua+(shop[buy][1])*0.8
                    print('购买成功，剩余金额为{}元'.format(money))
                    hao-=1
                elif you==0 and buy==6 and zhou>0:
                    money = money - (shop[buy][1]) * 0.9
                    hua = hua + (shop[buy][1]) * 0.9
                    print('购买成功，剩余金额为{}元'.format(money))
                    zhou-=1
                else:
                    money = money - shop[buy][1]
                    hua = hua + shop[buy][1]
                    print('购买成功，剩余金额为{}元'.format(money))
                if man<=hua:
                    print('本次已消费满200，返现十元')
                    money=money+10
                    man=man+man
            elif money>=2:
                print('钱不够了，买点别的吧！')
            else:
                print('没钱了，拿着小票gun！')
                for i, y in enumerate(car):
                    print(i, y)
                break
    elif buy == 'q' or buy == 'Q':
        print('欢迎下次光临！以下是您的小票：')
        for i, y in enumerate(car):
            print(i, y)
        print('剩余金额为{}元'.format(money))
        break
    else:
        print('输入有误，请重新输入！')
